<?php

class Application_Form_WorktimeAvailabilitytoworktime extends Zend_Form
{
    // Mapping keys to db columns
    protected static $DB_MAPPING = array(
		"description" => "description",
		"request" => "request",
		"request_additional" => "request_additional",
		"date_from" => "date_from",
		"date_to" => "date_to",
		"serie_from" => "serie_from",
		"serie_to" => "serie_to",
		"once_serie" => "once_serie",
        "expire_date" => "expire_date"
    );
    
    // Mapping Max Length from db
    protected static $MAX_LENGTH = array (
		"description" => "2500",
		"request" => "2500",
		"request_additional" => "2500",
		"event_type" => "10"
    );

    public function init()
    {
	    // Validators
	    $valid_date = new Zend_Validate_Date(array('format' => 'dd.MM.yyyy'));
	    $valid_datetime = new Zend_Validate_Date(array('format' => 'dd.MM.yyyy HH:mm'));
	    $valid_notempty = new Zend_Validate_NotEmpty();

	    $this->setMethod('post');
	
	
	    $this->addElement('select', "Mitarbeiter", array(
	        'label' => 'Verfügbarer Mitarbeiter:* ',
	        'required' => true,
	        'MultiOptions' => array(),
	        'validators' => array()
	    ));

	    $this->addElement('text', $this::$DB_MAPPING['date_from'], array(
	        'label' => 'Startdatum:* ',
	        'required' => true,
	        'filters' => array('StringTrim'),
	        'validators' => array($valid_notempty, $valid_datetime),
            'attribs' => array('readonly' => 'readonly')
	    ));
	
	    $this->addElement('text', $this::$DB_MAPPING['date_to'], array(
	        'label' => 'Enddatum:* ',
	        'required' => true,
	        'filters' => array('StringTrim'),
	        'validators' => array($valid_notempty, $valid_datetime),
            'attribs' => array('readonly' => 'readonly')            
	    ));
        
	    $this->addElement('select', "generation_method", array(
	        'label' => 'Generierung für:* ',
	        'required' => false,
	        'MultiOptions' => array(0=>'Diese Verfügbarkeit',
                                    1=>'Die Ganze Serie dieser Verfügbarkeit',
                                    2=>'Verfügbarkeit + die Serie davor',
                                    3=>'Verfügbarkeit + die Serie danach'),
	        'validators' => array()
	    ));
        
	    $this->addElement('textarea', $this::$DB_MAPPING['description'], array(
	        'label' => 'Beschreibung für die zu generierende Arbeitszeit: ',
	        'required' => false,
	        'filters' => array('StringTrim'),
	        'validators' => array(
		    $valid_notempty, 
		    array("StringLength",false,
		    array('max' => $this::$MAX_LENGTH['description']))
	    )));        
        
	    $this->addElement('submit', 'submit', array(
	        'ignore' => true,
	        'label' => 'Speichern'
	    ));
        
	    $this->addElement('hidden', "modus", array(
	        'required' => true
	    ));        
        
	
    }
}
